package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 公司配置枚举
 *
 * @author hongxiao
 * @date 2019-01-21 16:55
 */
@Getter
@ToString
public enum CompanyConfigEnum {
    /**
     * 公司配置
     */
    ONLY_IN_FORM_CHECK_SET("onlyInFormCheckSet","仅模板内判重", "0", 0),


    CUSTOMER_NAME_CHECK_SET("customerNameCheck","客户名称判重", "1", 0),


    CUSTOMER_PHONE_CHECK_SET("customerPhoneCheck","客户电话判重", "1", 0),


    CONTACT_PHONE_CHECK_SET("contactPhoneCheck","联系人电话判重是否开启", "", 0),


    CUS_PHONE_RULE_SET("cusPhoneRule","用户自定义电话号码的判断规则", "", 0),


    CONTRACT_PERFORMANCE_RULE_SET("contractPerformanceRule","enum.companyConfig.name.contract_performance_rule_set", "0", XbbRefTypeEnum.CONTRACT.getCode()),


    CONTRACT_NAME_CHECK_SET("contractNameCheck","合同名称判重是否开启", "", 0),


    CONTRACT_OUTSTOCK_OVER_SET("contractOutstockOverSet","允许合同出库产品和数量与关联产品不一致", "", 0),


    CONTRACT_NEW_SHOW_PRODUCE("contractNewShowProduce","新建合同订单", "1", 0),


    CONTRACT_IMPORT_SHOW_PRODUCE("contractImportShowProduce","导入新合同订单", "", 0),


    VISIT_IS_GALLERY_CHECK("visitIsGalleryCheck","是否允许调用图片库", "", 0),


    VISIT_IS_ADDRESS_CHECK("visitIsAddressCheck","是否允许修改地理位置", "", 0),


    VISIT_IS_AUTO_AFTER_CALL_CHECK("visitIsAutoAfterCallCheck","拨号后自动添加跟进记录", "", 0),


    PURCHASE_PRODUCT_RELATE("purchaseProductRelate","供应商和产品强制关联", "", 0),


    OUTSTOCK_CHECK_SET("outstockCheck","库存不足不允许出库是否开启", "", 0),


    OUTSTOCK_SALE_PRICE("outstockSalePrice","销售价格是否展示在出库单中", "", 0),

    /**
     * 0是不显示空数据
     * 1是显示空数据
     */
    PK_NULL_DATA("pkNullData","enum.companyConfig.name.pk_null_data", "0", 0),


    PK_LEAVE("pkLeave","enum.companyConfig.name.pk_leave", "0", 0),


    REPORT_TARGETSET("reportTargetSet","简报指标设置", "", 0),


    CHECKISGRAB("checkIsGrab","客户查重处是否允许抢公海客户", "1", 0),


    CHECKISADDTEAM("checkIsAddTeam","客户查重处是否允许加入团队操作", "0", 0),


    ADD_TO_TEAM_MAIN("addToTeamMain","加入团队成主负责人", "", 0),


    DAILY_REPORT_VISIBLE_SCOPE("dailyReportVisibleScope","日报可见范围", "", 0),


    DAILY_REPORT_STATISTIC_SET("dailyReportStatisticSet","日报统计设置", "", 0),


    DAILY_REPORT_DEADLINE("dailyReportDeadline","日报提交截止时间", "", 0),


    WEEKLY_REPORT_VISIBLE_SCOPE("weeklyReportVisibleScope","日报可见范围", "", 0),


    WEEKLY_REPORT_STATISTIC_SET("weeklyReportStatisticSet","日报统计设置", "", 0),


    WEEKLY_REPORT_DEADLINE("weeklyReportDeadline","日报提交截止时间", "", 0),


    MONTHLY_REPORT_VISIBLE_SCOPE("monthlyReportVisibleScope","日报可见范围", "", 0),


    MONTHLY_REPORT_STATISTIC_SET("monthlyReportStatisticSet","日报统计设置", "", 0),


    MONTHLY_REPORT_DEADLINE("monthlyReportDeadline","日报提交截止时间", "", 0),


    WORK_REPORT_EDIT_TIME_LIMIT("workReportEditTimeLimit","工作报告编辑时间限制", "", 0),


    BRUSH_APPROVAL_DATA("brushApprovalData","v3.8审批改版刷数据", "", 0),


    THOUSAND_SWITCH("thousandSwitch","万元开关：0元，1万元", "", 0),


    WHITE_CORPIDS("whiteCorpids","公司白名单", "", 0),


    DECIMAL_DIGITS("decimalDigits","自定义产品模板中数字输入的小数点位数", "", 0),


    MAIN_CONTACT("mainContact","是否开启主联系人", "", 0),


    CONTACT_REQUIRED_SET("contactRequired","联系人是否必填", "", 0),


    PRINT_LIMT_NUM("printLimtNum","打印模板每个业务模板对应的限制数量，默认值为3", "3", 0),


    PUBLIC_RULE_REMIND_TIME("publicRuleRemindTime","即将退回公海池提醒，需提前提醒的天数", "3", 0),

    CLUE_PUBLIC_RULE_REMIND_TIME("cluePublicRuleRemindTime","即将退回公海池提醒，需提前提醒的天数", "3", 0),

    PUBLIC_RULE_CUSTOMER_SENIOR_REMIND_TIME("publicCustomerSeniorRemind", "客户即将退回公海池提醒，需提前提醒的天数", "3", 0),

    PUBLIC_RULE_CLUE_SENIOR_REMIND_TIME("publicClueSeniorRemind", "线索即将退回公海池提醒，需提前提醒的天数", "3", 0),

    TRANSFER_RULE_CUSTOMER_SENIOR_REMIND_TIME("transferCustomerSeniorRemind","客户即将转移公海池提醒，需提前提醒的天数","3",0),

    TRANSFER_RULE_CLUE_SENIOR_REMIND_TIME("transferClueSeniorRemind","线索即将转移公海池提醒，需提前提醒的天数","3",0),

    ENABLE_CUSTOMER_STAGE("enableCustomerStage","启用客户阶段", "", 0),


    AMOUNT_PRECISION("amountPrecision","金额小数点位数", "", 0),


    NUMBER_PRECISION("numberPrecision","数量小数点位数", "", 0),


    FISCAL_YEAR("fiscalYear","财年设置标记-此处只存月份", "1", 0),


    PERFORMANCE_SET("performanceSet","允许员工在移动端设置个人目标", "0", 0),


    PERFORMANCE_MANAGE_SET("performanceManageSet","允许主管及以上角色在移动端设置目标", "0", 0),


    AGG_DEPARTMENT_PERFOR("aggDepartmentPerfor","上级部门目标自动汇总", "0", 0),

    FIXED_LEAVE_MARK("fixedLeaveMark","当考核方式为\"固定数值\"的时候，汇总离职员目标", "1", 0),

    WORKING_DAY_MONTH("workingDayMonth","每月工作日天数", "21.5", 0),


    WORKING_DAY_WEEK("workingDayWeek","每周工作日天数", "5", 0),


    PERFORMANCE_FINISH_DOWN("performanceFinishDown","完成率颜色标识值下限", "40", 0),


    PERFORMANCE_FINISH_UP("performanceFinishUp","完成率颜色标识值上限", "80", 0),


    SHARE_FOCUS_CUSTOEMR("shareFocusCustomer","enum.companyConfig.name.share_focus_custoemr", "0", XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode()),


    SHARE_FOCUS_OPPORTUNITY("shareFocusOpportunity","enum.companyConfig.name.share_focus_opportunity", "0", XbbRefTypeEnum.SALES_OPPORTUNITY.getCode()),


    BI_WITH_ELASTIC("BIWithElastic","BI是否使用elastic搜索引擎作为数据源,0否，1是", "", 0),


    AUTH_ORG_SCOPES("authOrgScopes","钉钉授权范围", "", 0),


    DING_VISIBLE_SCOPES("dingVisibleScopes","钉钉可见范围", "", 0),


    PAAS_PACKAGE("paasPackage","增值套餐配置", "", 0),


    ZERO_STOCK("zeroStock","enum.companyConfig.name.zero_stock", "0", XbbRefTypeEnum.PRODUCT.getCode()),


    DINGTALK_WORKRECORD("dingtalkWorkrecord","钉钉待办同步", "", 0),


    PRO_PROFESSIONAL_EDITION_SET("proProfessionalEditionSet","pro专业版设置", "0", 0),


    RAIDERS_WHITE("raidersWhite","价值攻略白名单", "[]", 0),


    MIRROR_PERCENT("mirrorPercent","默认开启镜像的公司所占百分比", "10", 0),

    MIRROR_CHART_PREVIEW("mirrorChartPreview", "镜像图表预览参数", "{}", 0),

    RAIDERS("raiders","首页攻略卡片", "0", 0),


    AI_ASSISTANT_WHITE("aiAssistantWhite","智能助手白名单", "[]", 0),


    AI_ASSISTANT_NUM("aiAssistantNum","购买的智能助手数量", "0", 0),

    PUBLIC_GROUP_NUM("publicGroupNum", "公海池分组数", "50", 0),

    FINECLUE_EMAIL("fineClueEmail","精线索邮箱","",0),

    // 打印通用设置
    PRINT_PROCESS_RECORDS("printProcessRecords", "enum.companyConfig.name.print_process_records", "1", 0),
    PRINT_QR_CODE("printQrCode", "enum.companyConfig.name.print_qr_code", "0", 0),

    PC_I18N_PACK( "pcI18nPack", "pc端国际化语言包标示", "zh_CN", 0),

    I18N_WHITE("i18nWhite", "国际化使用白名单", "[]", 0),
    // 业务规则白名单
    BUSINESS_RULE_WHITE("businessRuleWhite", "业务规则白名单", "[]", 0),

    ENABLE_BATCH_SHELF_MANAGEMENT("enableBatchShelfManagement", "enum.companyConfig.name.enable_batch_shelf_management", "0", 0),

    ENABLE_SEQ_MANAGEMENT("enableSeqManagement", "enum.companyConfig.name.enable_seq_management", "0", 0),

    ENABLE_STOCK_FLOW_BILL("enableStockFlowBill", "enum.companyConfig.name.enable_stock_flow_bill", "1", 0),

    PACKAGE_WHITELIST("packageWhiteList", "套餐白名单", "[]", 0),

    ENABLE_MULTI_UNIT("enableMultiUnit", "enum.companyConfig.name.enable_multi_unit", "0", 0),

    AUTOMATICALLY_ASSIGNED("automaticallyAssigned", "enum.companyConfig.name.automatically_assigned", "0", 0),

    AUTOMATICALLY_ASSIGNED_SENIOR("automaticallyAssignedSenior", "enum.companyConfig.name.automatically_assigned_senior", "0", 0),

    AUTOMATICALLY_ASSIGNED_NUM("automaticallyAssignedNum", "线索分配规则最大数量", "20", 0),

    CONNECTOR_WHITE("connectorWhite","连接器白名单", "[]", 0),

    CONNECTOR("connector","应用连接开关", "0", 0),

    BLACKLIST_BIG_DATA_CORP("blacklistBigDataCorp","黑名单：数据量过大公司", "[]", 0),

    /**
     * 阿里云呼叫中心配置
     */
    ALIYUN_CALLCENTER_CONFIGURATION("aliyunCallcenterConfiguration", "enum.companyConfig.name.aliyunCallcenterConfiguration", "0", 0),

    /**
     * 优音云呼叫中心配置
     */
    UIN_YUN_CALL_CONFIGURATION("uinYunCallConfiguration", "enum.companyConfig.name.uinYunCallConfiguration", "0", 0),

    /**
     * 外接呼叫中心配置
     */
    EXTERNAL_CALL_CONFIGURATION("externalCallConfiguration", "enum.companyConfig.name.externalCallConfiguration", "0", 0),

    DW_TRIGGER_TIME("dwTriggerTime","数据预警上次触发时间", "0", 0),

    CREDIT_RULE("creditRule","信用额度设置", "0", 0),

    WRITE_OFF_RULE("writeOffRule","核销设置", "0", 0),

    ALIPAY("alipay","支付宝", "{}", 0),

    WECHAT("weChat","微信支付", "{}", 0),

    UNIONPAY("unionPay","银联支付", "{}", 0),

    OFFLINE("offline","线下支付", "{}", 0),

    PRICE_MANAGE("priceManage","价格管理", "{}", 0),

    ELECTRONIC_FACE_SHEET("electronicFaceSheet","电子面单", "{}", 0),

    LOGISTICS_TRACKING("logisticsTracking","物流跟踪", "{}", 0),

    ENABLE_PURCHASE_PASSAGE("enablePurchasePassage","待入库数量","1",0),

    ENABLE_MINI_STOCK("enableMiniStock","最低库存","1",0),

    WORKFLOW("workflow","是否开启工作流", "1", 0),

    PERFORMANCE_LEAVE("performanceLeave","enum.companyConfig.name.performance_leave", "1", 0),

    BUSINESS_SEARCH("businessSearch","工商查询","1",0),

    /**
     * 移动端首页模式(默认只有专注模式)
     */
    MOBILE_INDEX_MODE("mobileIndexMode","enum.companyConfig.name.mobile_index_mode", "[1]", 0),

    PRICE_SET_COUNT("priceSetNum","价目表数量限制", "100", 0),

    TPLUS("tplus","畅捷通T+","0",0),

    //oss文件上传大小限制
    UPLOAD_LIMIT_SIZE("uploadLimitSize",  "oss断点续传文件上传大小限制", "", 0),

    SUB_FORM_ROW_NUM("subFormRowNum","子表单行数", "{}", 0),

    //公海池模式
    CUSTOMER_PUBLIC_POOL_SENIOR_MODEL("customerPublicPoolSeniorModel","客户公海池高级模式", "1", 0),

    ELASTICSEARCH_INDEX("elasticsearchIndex","es新索引白名单", "{}", 0),

    // 水印标识
    WATER_MARK("waterMarkState", "水印状态", "{\"companyNameWaterMarkDisplay\":0,\"userInfoWaterMarkDisplay\":0,\"waterMarkState\":0}", 0),
    USER_INFO_WATER_MARK_DISPLAY("userInfoWaterMarkDisplay", "用户信息水印显示", "0",0),
    COMPANY_NAME_WATER_MARK_DISPLAY("companyNameWaterMarkDisplay", "公司名称水印显示", "0", 0),

    CLUE_PUBLIC_POOL_SENIOR_MODEL("cluePublicPoolSeniorModel","线索公海池高级模式", "1", 0),

    //客户公海池模式切换中
    CUSTOMER_PUBLIC_POOL_CHANGE("customerPublicPoolChange","客户公海池模式切换中", "1", 0),
    //线索公海池模式切换中
    CLUE_PUBLIC_POOL_CHANGE("cluePublicPoolChange","线索公海池模式切换中", "1", 0),

    //列表支持阶段推进器停留时长
    STAGE_STAY_TIME("stageStayTime", "列表页支持展示阶段推进器停留时长", "[]", 0),

    GRAY_ENVIRONMENT_ENABLE("grayEnvironmentEnable","灰度环境是否启用", "0", 0),

    GRAY_CORPID_LIST("grayCorpidList","灰度公司名单","",0),

    SYSTEM_FORM_LIMIT_NUM("systemFormLimitNum","系统表单多模板数量上限", "6", 0),

    IMPORT_LARGE_NUM("importLargeNum","导入大数据量开关","1",0),

    ASSOCIATION_LIST("associationList","关联列表公司名单","[]",0),

    PROCESS_SERIAL_NO_SEARCH("processSerialNoSearch","审批流编号查询","[]",0),

    MAX_WORKFLOW_NODE("maxWorkflowNode","工作流最大节点数量","",0),
    // 销帮帮在钉钉中商品码
    DINGTALK_GOODS_CODE("dingtalkGoodsCode","销帮帮在钉钉中商品码","",0),

    WORK_ORDER_V2_POOL_SET("workOrderV2PoolSet","工单池","0",XbbRefTypeEnum.WORK_ORDER_V2_POOL.getCode()),


    SYSTEM_ROLE_NUM("systemRoleNum","系统角色数量","50",0),
    //菜单跨应用拖动白名单
    MENU_WHITE("menuWhite", "菜单跨应用拖动白名单", "[]", 0),

    CONTRACT_COMPARE_KEY("contractCompareKey", "合同比对秘钥","" ,0),

    CONTRACT_COMPARE_USEED("contractCompareUseed","合同比对用量","",0),

    MIGRATION_FILE_SUFFIX_LIST("migrationFileSuffixList","数据迁移支持的文件扩展名","",0),

    MIGRATION_WHITE_LIST("migrationWhitelist","数据迁移支持导入导出附件图片的公司白名单","",0),

    SHARE_PERMISSION_LIMIT("sharePermissionFormRuleNum","共享权限各表单规则数","",0),

    SHARE_PERMISSION_WHITE_CORPIDS("sharePermissionWhiteCorpids","共享权限公司白名单","",0),

    // 在线编辑器
    ONLINE_EDITOR_WHITE("onlineEditorWhite","wps在线编辑器白名单", "1", 0),
    ;

    /**
     * 配置别名
     */
    private final String alias;
    /**
     * 配置名称
     */
    private final String name;
    /**
     * 配置值
     */
    private final String value;
    /**
     * 业务类型
     */
    private final int businessType;
    /**
     * 备注tips
     */
    private String memo;
    /**
     * 排序
     */
    private Integer sort;
    static {
        CompanyConfigEnum.ENABLE_STOCK_FLOW_BILL.memo = "enum.companyConfig.memo.enable_stock_flow_bill";
        CompanyConfigEnum.ENABLE_BATCH_SHELF_MANAGEMENT.memo = "enum.companyConfig.memo.enable_batch_shelf_management";
        CompanyConfigEnum.ENABLE_SEQ_MANAGEMENT.memo = "enum.companyConfig.memo.enable_seq_management";
        CompanyConfigEnum.ENABLE_MULTI_UNIT.memo = "enum.companyConfig.memo.enable_multi_unit";
        CompanyConfigEnum.ENABLE_PURCHASE_PASSAGE.memo = "enum.companyConfig.memo.enable_purchase_passage";
        CompanyConfigEnum.ENABLE_MINI_STOCK.memo = "enum.companyConfig.memo.enable_mini_stock";
        CompanyConfigEnum.ENABLE_STOCK_FLOW_BILL.sort = 1;
        CompanyConfigEnum.ENABLE_BATCH_SHELF_MANAGEMENT.sort = 2;
        CompanyConfigEnum.ENABLE_SEQ_MANAGEMENT.sort = 3;
        CompanyConfigEnum.ENABLE_MULTI_UNIT.sort = 4;
        CompanyConfigEnum.ENABLE_PURCHASE_PASSAGE.sort = 5;
        CompanyConfigEnum.ENABLE_MINI_STOCK.sort = 6;
    }

    CompanyConfigEnum(String alias, String name, String value, int businessType) {
        this.alias = alias;
        this.name = name;
        this.value = value;
        this.businessType = businessType;
    }

    /**
     * 根据别名获取配置枚举
     * @param alias 配置别名
     * @return CompanyConfigEnum
     */
    public static CompanyConfigEnum getByAlias(String alias) {
        CompanyConfigEnum[] arr = values();

        for (CompanyConfigEnum cache : arr) {
            if (alias.equals(cache.getAlias())) {
                return cache;
            }
        }

        return null;
    }

    /**
     * 根据业务类型获取配置枚举
     * @param businessType 业务类型
     * @return CompanyConfigEnum
     */
    public static List<CompanyConfigEnum> getByBusinessType(Integer businessType) {
        List<CompanyConfigEnum> companyConfigEnumList = new ArrayList<>();
        for (CompanyConfigEnum companyConfigEnum : values()) {
            if (Objects.equals(businessType, companyConfigEnum.getBusinessType())) {
                companyConfigEnumList.add(companyConfigEnum);
            }
        }
        return companyConfigEnumList;
    }
    /**
     * 获取所有枚举
     * @return List<CompanyConfigEnum>
     */
    public static List<CompanyConfigEnum> getAllEnum() {
        return new ArrayList<>(Arrays.asList(values()));
    }

    /**
     * 获取所有配置别名
     * @return List<String>
     */
    public static List<String> getAllEnumAlis() {
        List<String> list = new ArrayList<>();
        CompanyConfigEnum[] arr = values();

        for (CompanyConfigEnum cache : arr) {
            list.add(cache.getAlias());
        }

        return list;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
